#ifndef _CommonUtill_
#define _CommonUtill_

#include <sys/time.h>

#ifdef __cplusplus
extern "C"
{
#endif

#define DATE_FORMATE_YMDHMS            "%Y-%m-%d %H:%M:%S"
#define DATE_FORMATE_YMDHMSms          "%Y-%m-%d %H:%M:%S:ms"
#define DATE_FORMATE_YMD_HMS           "%Y-%m-%d-%H:%M:%S"
#define DATE_FORMATE_Y_M_D_H_M_S       "%Y_%m_%d_%H_%M_%S"
#define DATE_FORMATE_Y_M_D_H_M_S_ms    "%Y_%m_%d_%H_%M_%S_ms"
#define DATE_FORMATE_HMS               "%H:%M:%S"
#define DATE_FORMATE_Y_M_D             "%Y_%m_%d"
#define DATE_FORMATE_Y_M_D_CONNECT_CHAR             "%Y-%m-%d"

#define COMPARE_EQAUL                    (0)
#define COMPARE_LESS_THAN                (-1)
#define COMPARE_MORE_THAN                (1)
#define COMPARE_INVALID                  (100)
#define COMPARE_UNKNOWN                  (101)

void setSystemTime(const char *timestamp);
void getCurrentTime(char *buffer, const char *formate);
int getCurrentWeekDay();
int getCurrentHour();

int isFastOperator(int diffMillons, struct timeval *lastTv);

int com_get_random(int min, int max);

int com_create_once_task_thread(void* (*taskFunction)(void*), void *param);

int compareWithCurrent(const char *hmsTime);
int compareWithYMD(const char *compareYMD, const char *currentYMD);

#ifdef __cplusplus
}
#endif

#endif